import unittest
import requests
import jsonschema


class TestIhrmLogin(unittest.TestCase):

    def test01_login_success(self):
        url = "http://ihrm-test.itheima.net/api/sys/login"
        json_data = {
            "mobile": "13800000002",
            "password": "123456"
        }
        resp = requests.post(url=url, json=json_data)

        print(resp.json())
        self.assertEqual(200, resp.status_code)

        # 全量字段对响应结果实施 校验！
        schema = {
            "type": "object",
            "properties": {
                "success": {"const": True},
                "code": {"const": 10000},
                "message": {"pattern": "操作成功"},
                "data": {"type": "string"}
            }
        }
        jsonschema.validate(resp.json(), schema=schema)

        # self.assertEqual(10000, resp.json().get("code"))
        # self.assertEqual(True, resp.json().get("success"))
        # self.assertIn("操作成功", resp.json().get("message"))
